# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - patch to fix AArch64 build

pkgname=webrtc-audio-processing
pkgver=0.3.1
pkgrel=5
pkgdesc="AudioProcessing library based on Google's implementation of WebRTC"
url="https://freedesktop.org/software/pulseaudio/webrtc-audio-processing/"
arch=(x86_64)
license=(custom)
depends=(gcc-libs)
makedepends=(git)
provides=(libwebrtc_audio_processing.so)
_commit=e882a5442ac22c93648e12837248d651d18b9247  # tags/v0.3.1^0
source=("git+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing.git#commit=$_commit"
        'webrtc-fix-typedefs-on-other-arches.patch')
b2sums=('SKIP'
        'dd71fc3117ce1e1ead2ce1af21177ea5ca139bc6ba285a252d1f83de497ff685ba73c315a65f1fb315740d5d5dd5a99ad61db6cbff5cff5349709ea39d61bc09')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
  patch -p1 -i ../webrtc-fix-typedefs-on-other-arches.patch
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  local configure_options=(
    --prefix /usr
    --disable-static
  )

  cd $pkgname
  ./configure "${configure_options[@]}"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}

# vim:set sw=2 sts=-1 et:
